package com.weilele.leisure.time.ui.module.video_detail


import androidx.activity.OnBackPressedCallback
import com.weilele.base.library.BaseBindingFragment
import com.weilele.leisure.time.databinding.FragmentVideoPlayerBinding
import com.weilele.mvvm.base.helper.createViewModel
import com.weilele.mvvm.base.livedata.LiveDataWrap
import com.weilele.mvvm.base.livedata.wrapSuccessObserver

class VideoPlayerFragment : BaseBindingFragment<FragmentVideoPlayerBinding>() {

    private val videoViewModel by lazy { requireParentFragment().createViewModel<VideoDetailViewModel>() }

    override fun getObserverLiveData(): List<LiveDataWrap>? {
        return listOf(
            videoViewModel.playerHelperData wrapSuccessObserver {
                it.setPlayerVideoView(mBinding.root)
            }
        )
    }

    override fun onBackPressed(): OnBackPressedCallback? {
        return object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                mBinding.root.onClickBack(view)
            }
        }
    }
}